#include<bits/stdc++.h>
#define int long long
#define For(i,a,b) for(int i=a;i<=b;++i)
#define Rof(i,a,b) for(int i=a;i>=b;--i)
#define rep(i,a) for(int i=1;i<=a;++i)
#define print(x) printf("%lld\n",(int)x)
#define prn(x) printf("%lld ",(int)x)
using namespace std;
const int N=2e6+5,Mod=998244353;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){f=(ch=='-'?-f:f);ch=getchar();}
	while(isdigit(ch)){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
	return x*f;
}
int n,a[N];
vector<int>q[N];
int sum[N];
int in[N];
bool flag=0;
int dfs(int x,int faz){
	//~ cout<<x<<" "<<siz[x]<<endl;
	int s=0;
	if(in[x]==1)return a[x];
	for(auto y:q[x]){
		if(y==faz) continue;
		s+=dfs(y,x);
	}
	if(2*a[x]-s<0||2*a[x]-s>a[x])return -INT_MAX;
	return 2*a[x]-s;
}
inline void solve(){
	n=read();
	For(i,1,n)a[i]=read();
	For(i,1,n) q[i].clear(),in[i]=0;
	if(n==1){
		if(a[1]==0) puts("YES");
		else puts("NO");
		
		return;
	}
	if(n==2){
		if(a[1]==a[2]) puts("YES");
		else puts("NO");
		return;
	}
	For(i,1,n) sum[i]=0;
	int rt=0;
	For(i,1,n-1){
		int u=read(),v=read();
		q[u].push_back(v),q[v].push_back(u);
		in[u]++,in[v]++;
	}
	For(i,1,n){if(in[i]>1)rt=i;}
	if(dfs(rt,0)==0) puts("YES");
	else puts("NO");
}
signed main(){
	freopen("clean.in","r",stdin);
	freopen("clean.out","w",stdout);
	int T=read();
	while(T--)solve();
	return 0;
}
//
